//方法对象
const Storage = {
    getItem:function(hehe){
        let res = haha.hehe
        let arr = Object.prototype.toString.call(res.split(','))
        let str = Object.prototype.toString.call(res)
        let type = arr.slice(1,arr.length-1).split(' ')[1]
        let obj = JSON.parse(res)
        console.log(obj);
        let obj1 = Object.prototype.toString.call(obj)
        let type1 = obj1.slice(1,obj1.length-1).split(' ')[1]
        let type2 = str.slice(1,str.length-1).split(' ')[1]
        console.log(type,type1,type2);
        if( type === 'Array' ){
            let arr = []
            res.split(',').forEach(item => {
                item = Number(item)
                arr.push(item)
            })
            return arr
        }else if(type2 === 'String'){
           return res 
        }else if(type2 === 'Object'){
            return JSON.parse(res)
        }
    },
    setItem:function(hehe,item){
        const res = Object.prototype.toString.call(item)
        let type = res.slice(1,res.length-1).split(' ')[1]
        let obj = {}
        if(type === 'String'){
            obj[hehe] = item
            return obj
        }else if(type === 'Object'){
            const str = JSON.stringify(item)
            obj[hehe] = str
            return obj
        }else if(type === 'Array'){
            const arr = item.join(',')
            obj[hehe] = arr
            return obj
        }
    }
}

